Skip to content

Conversation

bassiounix
Copy link
Contributor

@bassiounix bassiounix commented Oct 18, 2025

RFC https://discourse.llvm.org/t/rfc-bounds-checking-interfaces-for-llvm-libc/87685

Add ignore_handler_s required by Annex K interface in LLVM libc.

Copy link
Contributor Author

bassiounix commented Oct 18, 2025

@llvmbot
Copy link
Member

llvmbot commented Oct 18, 2025

@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-libc

Author: Muhammad Bassiouni (bassiounix)

Changes

[libc][stdlib][annex_k] Add ignore_handler_s.

temp change


Full diff: https://github.com/llvm/llvm-project/pull/164090.diff

8 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+1)
  • (modified) libc/config/linux/riscv/entrypoints.txt (+1)
  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/include/CMakeLists.txt (+1)
  • (modified) libc/include/stdlib.yaml (+9)
  • (modified) libc/src/stdlib/CMakeLists.txt (+13)
  • (added) libc/src/stdlib/ignore_handler_s.cpp (+16)
  • (added) libc/src/stdlib/ignore_handler_s.h (+22)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 8bf6c44b1d669..bfff3767e245a 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -1080,6 +1080,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.stdlib.atexit
     libc.src.stdlib.exit
     libc.src.stdlib.getenv
+    libc.src.stdlib.ignore_handler_s
     libc.src.stdlib.quick_exit
 
     # signal.h entrypoints
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index dffccbab9a8e9..35916c86ee9ab 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -1208,6 +1208,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.stdlib.atexit
     libc.src.stdlib.exit
     libc.src.stdlib.getenv
+    libc.src.stdlib.ignore_handler_s
     libc.src.stdlib.quick_exit
 
     # signal.h entrypoints
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index b4ab073ec912f..45e4d266f87b7 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1247,6 +1247,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.stdlib.atexit
     libc.src.stdlib.exit
     libc.src.stdlib.getenv
+    libc.src.stdlib.ignore_handler_s
     libc.src.stdlib.quick_exit
 
     # signal.h entrypoints
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 3266b57bc8ecd..74ec0a1078b0c 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -360,6 +360,7 @@ add_header_macro(
   ../libc/include/stdlib.yaml
   stdlib.h
   DEPENDS
+    .llvm-libc-macros.annex_k_macros
     .llvm-libc-macros.null_macro
     .llvm-libc-macros.stdlib_macros
     .llvm-libc-types.__atexithandler_t
diff --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index 29fd6bc3a1e75..aed4728a07552 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -110,6 +110,15 @@ functions:
     return_type: char *
     arguments:
       - type: const char *
+  - name:  ignore_handler_s
+    standards:
+      - stdc
+    return_type: void
+    arguments:
+      - type: const char *__restrict
+      - type: void *__restrict
+      - type: errno_t
+    guard: 'LIBC_HAS_ANNEX_K'
   - name: labs
     standards:
       - stdc
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index c464f82dcbda7..a70c3d6210210 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -653,3 +653,16 @@ add_entrypoint_object(
   DEPENDS
     .${LIBC_TARGET_OS}.system
 )
+
+add_entrypoint_object(
+  ignore_handler_s
+  HDRS
+    ignore_handler_s.h
+  SRCS
+    ignore_handler_s.cpp
+  DEPENDS
+    libc.hdr.types.errno_t
+    libc.src.__support.libc_errno
+    libc.src.__support.macros.config
+    libc.src.__support.macros.attributes
+)
diff --git a/libc/src/stdlib/ignore_handler_s.cpp b/libc/src/stdlib/ignore_handler_s.cpp
new file mode 100644
index 0000000000000..172b1bcdb7b30
--- /dev/null
+++ b/libc/src/stdlib/ignore_handler_s.cpp
@@ -0,0 +1,16 @@
+//===-- Implementation header for ignore_handler_s --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdlib/ignore_handler_s.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, ignore_handler_s,
+                   (const char *__restrict, void *__restrict, errno_t)) {}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/ignore_handler_s.h b/libc/src/stdlib/ignore_handler_s.h
new file mode 100644
index 0000000000000..07328d4be01ce
--- /dev/null
+++ b/libc/src/stdlib/ignore_handler_s.h
@@ -0,0 +1,22 @@
+//===-- Implementation header for ignore_handler_s --------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_STDLIB_IGNORE_HANDLER_S_H
+#define LLVM_LIBC_SRC_STDLIB_IGNORE_HANDLER_S_H
+
+#include "hdr/types/errno_t.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+void ignore_handler_s(const char *__restrict msg, void *__restrict ptr,
+                      errno_t error);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_STDLIB_IGNORE_HANDLER_S_H

@bassiounix bassiounix marked this pull request as ready for review October 18, 2025 14:16
@bassiounix bassiounix changed the base branch from users/bassiounix/spr/10-13-_libc_annex_k_add_constraint_handler_t to users/bassiounix/spr/10-14-_libc_annex_k_add_abort_handler_s October 18, 2025 14:40
@bassiounix bassiounix force-pushed the users/bassiounix/spr/10-14-_libc_stdlib_annex_k_add_ignore_handler_s branch from 0b20953 to 5d96de6 Compare October 18, 2025 14:40
@bassiounix bassiounix force-pushed the users/bassiounix/spr/10-14-_libc_annex_k_add_abort_handler_s branch from 611fd5f to 37f49e3 Compare October 18, 2025 14:40
@bassiounix bassiounix force-pushed the users/bassiounix/spr/10-14-_libc_annex_k_add_abort_handler_s branch from 37f49e3 to 6a9bfac Compare October 18, 2025 15:02
@bassiounix bassiounix force-pushed the users/bassiounix/spr/10-14-_libc_stdlib_annex_k_add_ignore_handler_s branch from 5d96de6 to ab947f3 Compare October 18, 2025 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants